#pragma once
#ifndef ALIOSSADAPTER_H
#define ALIOSSADAPTER_H

#include <QObject>
#include <QNetworkReply>
#include <QNetworkAccessManager>

#include "AliOSSUploadRequest.h"
#include "AliOSSRemoveRequest.h"
#include "AliOSSCopyRequest.h"

namespace AliOSS
{
	class AliOSSUploadRequest;
	class AliOSSRemoveRequest;
	class AliOSSCopyRequest;
    class AliOSSAdapter : public QObject
    {
        Q_OBJECT
    public:
        AliOSSAdapter(
            const QString &bucket,
            const QString &accessId,
            QObject *parent = nullptr);
        ~AliOSSAdapter();
    public:
        /*! Prepare a upload action
         * A Uploader will be returned, then you can fetch md5inbase64 to generate a access signature
         * \note Do remember to delete the Uploader returned.
         * */
        AliOSSUploadRequest *prepareUpload(const QByteArray &data);

		/*! Prepare a delete(remove) action
		* A AliOSSRemoveRequest will be returned, then you can fetch ossHeader to generate a access signature
		* \note Do remember to delete the AliOSSRemoveRequest returned.
		* */
		AliOSSRemoveRequest *prepareRemove(const QString &path);

		AliOSSCopyRequest *prepareCopy(const QString &srcPath, const QString &dstPath);

    public:
        static QString formatDatetime(QDateTime datetime);
    public:
        friend class AliOSSUploadRequest;
        QString bucket;
        QString accessId;
        QNetworkAccessManager *networkAccessManager = nullptr;

    };
}

#endif // ALIOSSADAPTER_H
